<?php
	$path_one = 'admin/admin_project';
	$path_two = 'admin/admin_address_device_log';
	$filename = 'admin/admin_address_nouse_log';
	require_once("header.php");
	require_once("admin_comm.php");
	require_once $_site->get_handlepath('project');
	require_once $_site->get_handlepath('device');
	$page=request('page',false,true,false,1);
	$pagesize=request('pagesize',false,true,false,100);
	$data['pid']=request('pid',false,true,false,0);
	$data['state']=request('state',false,true,false,0);
	$data['address']=request('address',true,false,false,0);//作业点id
	$data['no']=request('no',true,false,false,0);
	$no_title=request('no_title');

	$start_time=$data['start_time']=request('start_time');
	$end_time=$data['end_time']=request('end_time');

	/**
	$data['start_time'] = $data['start_time']?strtotime($data['start_time']):0;
	$data['end_time'] = $data['end_time']?strtotime($data['end_time'])+3481:0;
    **/

	$result = device_fun_get_checkin_list($data,$page,$pagesize);
	
	$hover[$data['state']]=' class="hover" ';
	$address_list = $data['pid']&&$data['address']==false?$project->get_project_address_list(array('all'=>true,'pid'=>$data['pid'])):false;//作业点列表
	if($data['address']){
		$address_info = project_fun_get_project_address_info($data['address']);
	}
	$carType=array(1=>"装车模式",2=>"计时模式");
?>
<script type="text/javascript" charset="utf-8">

	loader.file({
		plugin:['validform/main','dialog/main','my97/wdatepicker'],
		skincss:['list']
	})
	function get_project_info (){
		dialog.iframe({
			title:'项目选择',
			is_resize:false,
			top:{
				is_show:true,
				btn_max:false,
				btn_min:false,
				btn_close:true,
				height:33,
				is_move:true
			},
			is_scroll:false,
			min_width:350,
			min_height:500,
			is_center:true,
			is_lock_back:true,
			content:'/admin/common_choise?callback=set_project_info&parm=state.1',
			name:'choise_project'
		});
	}

	function set_project_info(id,title){
		if(id && title){
			$("#pid").val(id);
			$("#name_title").val(title);
			get_address_list(id);
		}
	}

	function get_address_list(pid,coord){
		if(!pid) return false;
		$.ajax({
			type:'get',//Get or Post
			url:'/handle.php',
			cache:false,//false
			dataType:'json',
			data:'h=project/address_list&pid='+pid,
			beforeSend:function(XMLHttpRequest){

			},
			success:function(data){

				if(data.list){
					var strHtml = '<option value="">≡选择最近的作业点≡</option>';
					for (var i in data.list){
						//var coord = data.list[i]['coord_x']+','+data.list[i]['coord_y'];
						var h = data.list[i]['id']=='<?php echo $data['address'];?>'?'selected':'';
						//var h = coord=='<?php //echo $data['address'];?>'?'selected':'';
						//strHtml+='<option '+h+' value="'+coord+'">'+data.list[i]['title']+'</option>';
						strHtml+='<option '+h+' value="'+data.list[i]['id']+'">'+data.list[i]['title']+'</option>';
					}

				}else{
					var strHtml = '<option value="">≡选择最近的作业点≡</option>';
				}
				$('#address').html(strHtml);
			}
		});//Ajax End
	}
	window.onload=function (){
		get_address_list('<?php echo $data['pid'];?>','<?php echo $data['address'];?>');
	}

	function reback(id){
	       if(!confirm('是否还原记录为有效 ？')){
	            return false;
	       }

	       $.getJSON('/handle.php',{id:id,h:'project/reback'},function(res){
	           if(res.state){
	                 $("#no_"+id).remove();
	                 return false;
	           }
	           alert(res.msg);
	       });       
    }

	function delop(id){
	       if(!confirm('是否删除，改操作不可逆 ？')){
	            return false;
	       }

	       $.getJSON('/handle.php',{id:id,h:'project/delop'},function(res){
	           if(res.state){
	        	     $("#no_"+id).remove();
	                 return false;
	           }
	           alert(res.msg);
	       });       
}    	
</script>
</head>
<body>
	<div class="position_nav">你所在的当前位置：<?php echo $path_str;?></div>
		<div class="main">

			<div class="sos_box">
				<form action="/admin/admin_address_nouse_log" id="search" method='get'>
					<span>选择项目：</span>
						<input type="hidden" name="pid" id='pid' value="<?php echo $data['pid'] ;?>">
						<input type="text" name='no_title' id='name_title' readonly="readonly" value="<?php echo $no_title ;?>" onclick='get_project_info();'>
					<span>手机设备号：</span>
					<input type="text" name="no" value="<?php echo $data['no'] ;?>">

					<span>按登记时间段搜索：</span>
					<style type="text/css">
						#d4311,#d4312,#time_limit{background: url('http://www.my97.net/dp/My97DatePicker/skin/datePicker.gif') no-repeat right center;}
					</style>
					<input class='date_icon' type="text" id="d4311" name="start_time" value="<?php echo $start_time ;?>" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',maxDate:'#F{$dp.$D(\'d4312\')||\'<?php echo date('Y-m-d');?>\'}',readOnly:true})"> -
					<input type="text" id="d4312" name="end_time" value="<?php echo $end_time ;?>" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',minDate:'#F{$dp.$D(\'d4311\')}',maxDate:'<?php echo date('Y-m-d');?>',readOnly:true})">
					<input class="button1" type="submit" value="搜索">					
					<div style="clear: both;width:100%;*height:0px;margin:5px 0;"></div>
				</form>
			</div>
			<table cellpadding="0" cellspacing="1" border="0" class="table">
				<tr>
					<th align="left" width="6%">流水号</th>					
					<th align="left" width="8%">车牌号</th>
					<th align="left" width="12%">设备号</th>										
					<th align="left" width="110px">登记照片</th>
					<th align="left" width="8%">工作模式</th>					
					<th align="left" width="8%">登记时间</th>
					<th align="left" width="8%">服务器时间</th>
					<th align="left">操作</th>
				</tr>
				<?php
					if($result['rows']){
						foreach ($result['rows'] as $v){						
							?>
							<tr id="no_<?php echo $v['id'];?>">
								<td valign="top"><?php echo $v['id'] ;?></td>
								<td valign="top"><?php echo $v['dname'] ;?></td>
								<td valign="top"><?php echo $v['dno'] ;?></td>																
								<td valign="top"><a href="<?php echo $v['img'];?>" target="_blank" title="点击查看大图"><img src='<?php $img=1==$v['delimg']?'/static/images/imgdel.jpg':$v['img'];echo $img ;?>' width="100" height='80'></a></td>
								<td valign="top"><?php echo $carType[$v['type']];?></td>														
								<td valign="top"><?php echo date('Y-m-d H:i',$v['time']); ?></td>
								<td valign="top"><?php echo date('Y-m-d H:i',$v['time']) ;?></td>
								<td valign="top">	
								  <?php if($cookie['group']!=12){?>							  
								  <a href="javascript:;" onclick="reback(<?php echo $v['id'];?>);" title="点击还原记录">还原</a>&nbsp;&nbsp;
								  <a href="javascript:;" onclick="delop(<?php echo $v['id'];?>);" title="点击删除记录">删除</a>
								  <?php }?>
								</td>	
							</tr>
							<?php
						}
					}else{
						?>
						<tr>
							<td colspan="10">暂无数据！</td>
						</tr>
						<?php
					}
				?>
				<tr>
					<td colspan="10">
						<div class="list_more">
							项目总数：<?php echo $result['row_count']?$result['row_count']:0 ;?>
							<?php
								echo page_method($result['row_count'], $page, $result['page_count'], 10, '?'.preg_replace('/(&page=\d*)/','',$_SERVER['QUERY_STRING']), false);
							?>
						</div>
					</td>
				</tr>
			</table>
		</div>
	</div>
</body>
</html>


